import { Component, OnInit, ViewChild } from '@angular/core';
import { NzFormatEmitEvent } from 'ng-zorro-antd';
@Component({
  selector: 'app-modal-tree',
  templateUrl: './modal-tree.component.html',
  styleUrls: ['./modal-tree.component.less']
})
export class ModalTreeComponent implements OnInit {
  @ViewChild('nzTree') nzTree: any
  defaultCheckedKeys = ['0-0-0'];
  // defaultSelectedKeys = ['0-0-0'];
  // checkedKeys = []
  // defaultExpandedKeys = ['0-0', '0-0-0', '0-0-1'];
  nodes = [
    {
      title: '0-0',
      key: '0-0',
      expanded: true,
      disabled: false,
      children: [
        {
          title: '0-0-0',
          key: '0-0-0',
          disabled: false,
          children: [
            { title: '0-0-0-0', key: '0-0-0-0', isLeaf: true },
            { title: '0-0-0-1', key: '0-0-0-1', isLeaf: true },
            { title: '0-0-0-2', key: '0-0-0-2', isLeaf: true }
          ]
        },
        {
          title: '0-0-1',
          key: '0-0-1',
          disabled: false,
          children: [
            { title: '0-0-1-0', key: '0-0-1-0', isLeaf: true },
            { title: '0-0-1-1', key: '0-0-1-1', isLeaf: true },
            { title: '0-0-1-2', key: '0-0-1-2', isLeaf: true }
          ]
        },
        {
          title: '0-0-2',
          key: '0-0-2',
          disabled: false,
          isLeaf: true
        }
      ]
    },
    {
      title: '0-1',
      key: '0-1',
      disabled: false,
      children: [
        { title: '0-1-0-0', key: '0-1-0-0', isLeaf: true },
        { title: '0-1-0-1', key: '0-1-0-1', isLeaf: true },
        { title: '0-1-0-2', key: '0-1-0-2', isLeaf: true }
      ]
    },
    {
      title: '0-2',
      key: '0-2',
      disabled: false,
      isLeaf: true
    }
  ];
  constructor() { }

  ngOnInit() {
  }

  nzEvent(event: NzFormatEmitEvent): void {
    console.log(event);
  }

  nzClick(event: NzFormatEmitEvent): void {
    event.keys = []
    console.log(event);
  }

  getTreeNodeStatus() {
    console.log('getTreeNodes', this.nzTree.getTreeNodes())
    console.log('getHalfCheckedNodeList', this.nzTree.getHalfCheckedNodeList())
    console.log('getCheckedNodeList', this.nzTree.getCheckedNodeList())
  }
}
